package com.leyou.item.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leyou.item.dto.SpecParamDTO;
import com.leyou.item.entity.SpecParam;
import com.leyou.item.exceptions.LyException;
import com.leyou.item.mapper.SpecParamMapper;
import com.leyou.item.service.SpecParamService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SpecParamServiceImpl extends ServiceImpl<SpecParamMapper, SpecParam> implements SpecParamService {
    @Override
    public List<SpecParamDTO> querySpecParam(Long categoryId, Long groupId, Boolean searching) {
        //健壮性判断
        if (categoryId==null&&groupId==null){
            throw new LyException(500,"分类id和组id不能都为空");
        }
        List<SpecParam> list1 = query().eq(categoryId!=null,"category_id", categoryId)
                .eq(groupId!=null,"group_id", groupId)
                .eq(searching!=null,"searching", searching)
                .list();
        return SpecParamDTO.convertEntityList(list1);
    }


}